/**
 * Created by 徐嘉宾 on 2016/8/24.
 */
$('#w0 tr').each(function () {
    var a = $(this).children('th').text();
    if (a == '一级分类') {
        var b = $(this).children('td');
        $.get("./?r=admin/getclass1", {"id": b.text()}, function (data) {
            b.html(data);
        });
    }
    if (a == '二级分类') {
        var c = $(this).children('td');
        $.get("./?r=admin/getclass2", {"id": c.text()}, function (data) {
            c.html(data);
        });
    }
});
$.get("./?r=admin/getreadtype1", function (data) {
    var a = data.split("/");
    for (var i = 0; i < a.length - 1; i++) {
        var j = a[i].split(" ");
        var k = "<option value='" + j[0] + "'>" + j[1] + "</option>";
        $('#comment-class1_id').append(k);
    }
});
$('#comment-class1_id').change(function () {
    $("#comment-class2_id option:not(:contains(' '))").remove();
    var b = $('#comment-class1_id option:selected').val();
    $.get("./?r=admin/getreadtype2", {id: b}, function (data) {
        var a = data.split("/");
        for (var i = 0; i < a.length - 1; i++) {
            var j = a[i].split(" ");
            var k = "<option value='" + j[0] + "'>" + j[1] + "</option>";
            $('#comment-class2_id').append(k);
        }
    });
});
if(c1!=false&&c2!=false) {
    $.get("./?r=admin/getclass1", {id: c1}, function (data) {
        var e = data;
        $('#comment-class1_id').append("<option value='" + c1 + "' selected='selected'>" + e + "</option>");
    });
    $.get("./?r=admin/getclass2", {id: c2}, function (data) {
        var f = data;
        $('#comment-class2_id').append("<option value='" + c2 + "' selected='selected'>" + f + "</option>");
    });
}
if (c3!='false'){
    $('#comment-is_up option').each(function () {
        var v = $(this).val();
        if (v==c3){
            $(this).attr("selected" ,true);
        }
    });
}